// 初始化 Swiper
var swiper = new Swiper(".mySwiper", {
  spaceBetween: 0,
  centeredSlides: true,
  autoplay: {
    delay: 2500,
    disableOnInteraction: false,
  },
  pagination: {
    el: ".swiper-pagination",
    clickable: true,
  },
  navigation: {
    nextEl: ".swiper-button-next",
    prevEl: ".swiper-button-prev",
  },
});

// 分类鼠标移入效果
let sort = document.querySelectorAll('.classify_cont>li')
let imgs = document.querySelectorAll('.classify_cont>li img')
// console.log(imgs);
sort.forEach(function (open, i) {
  // 鼠标移入效果
  open.addEventListener('mouseenter', function () {
    let route = imgs[i].src
    route = route.substr(0, route.length - 4)
    route += '-c' + '.svg'
    imgs[i].src = route
    open.classList.add('classify_cont_bg')
  })
  // 鼠标移出事件
  open.addEventListener('mouseleave', function () {
    let route = imgs[i].src
    route = route.substr(0, route.length - 6)
    route += '.svg'
    imgs[i].src = route
    open.classList.remove('classify_cont_bg')
  })
})


// 助力行业巨头 / 独角兽企业  轮播部分
let help = document.querySelectorAll('.help_cont li')

let item = 0;
let tiem = null
// 创建索引
function autoPlay() {
  tiem = setInterval(function () {
    help[item].className = '';
    item++;
    if (item === 3) {
      item = 0
    }
    help[item].className = 'opacity';
  }, 2000)
}
autoPlay()
let he = document.querySelector('.help_cont')
he.addEventListener('mouseover', function () {
  clearInterval(tiem)
  tiem = null
})
he.addEventListener('mouseout', function () {
  autoPlay();
})

// 鼠标移入事件  助力
let helpFoot = document.querySelectorAll('.help_foot img')
helpFoot.forEach(function (open, i) {
  open.addEventListener('mouseenter', function () {
    let way = open.src
    console.log(way);
    way = way.substr(0, way.length - 4)
    way += '-c' + '.svg'
    console.log(way);
    open.src = way
  })
  // 鼠标移出事件
  open.addEventListener('mouseleave', function () {
    let way = open.src
    console.log(way);
    way = way.substr(0, way.length - 6)
    way += '.svg'
    console.log(way);
    open.src = way
  })
})

// 回到顶部
function backTop() {
  // 鼠标滚动事件
  let returnTo = document.querySelector('.returnTo')
  // 创建鼠标滚动事件
  window.addEventListener('scroll', function () {
    // 判断当前位置
    if (document.documentElement.scrollTop >= 800) {
      returnTo.style.display = 'block'
    } else {
      returnTo.style.display = 'none'
    }
  })
  // 创建点击事件 
  let hour = null
  returnTo.addEventListener('click', function () {
    // 创建一个定时器
    hour = setInterval(function () {
      document.documentElement.scrollTop -= 50;
      if (document.documentElement.scrollTop <= 0) {
        clearInterval(hour)
        hour = null
      }
    }, 50)
  })
}
backTop()

// 获取登录按钮
let login=document.querySelector('.shop .login')
// console.log(login);
// 创建点击事件
login.addEventListener('click',function(e){
  let modal=document.querySelector('.modal') 
  // console.log(modal);
  modality(modal)
  modal.classList.add('modal_show')
  
  // modal.classList.remove('modal_show')
})








